﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;
using BLL;

public partial class admin_Order_Details : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnDuyet_Click(object sender, EventArgs e)
    {
      try {
      ProductBLL prodData = new ProductBLL();
      OrderDetailsBLL orderDetailData = new OrderDetailsBLL();
      OrderBLL orderData = new OrderBLL();
      int id = -1;
      if (Request.QueryString["Id"] != null)
        id = Convert.ToInt32(Request.QueryString["Id"]);

      orderData.SetStatus(id, true);

        //Tru so luong san pham
        var listProd = orderDetailData.GetByOrderId(id);
        foreach (var item in listProd)
        {
          prodData.SubQuantity(item.IdProduct, item.Count);
        }
      }
      catch{}
    }
    protected void btnHuyDon_Click(object sender, EventArgs e)
    {
      try
      {
        ProductBLL prodData = new ProductBLL();
        OrderDetailsBLL orderDetailData = new OrderDetailsBLL();
        OrderBLL orderData = new OrderBLL();
        int id = -1;
        if (Request.QueryString["Id"] != null)
          id = Convert.ToInt32(Request.QueryString["Id"]);

        orderData.SetStatus(id, false);

        //Tru so luong san pham
        var listProd = orderDetailData.GetByOrderId(id);
        foreach (var item in listProd)
        {
          prodData.AddQuantity(item.IdProduct, item.Count);
        }
      }
      catch { }
    }
    protected void btnDanhSach_Click(object sender, EventArgs e)
    {
      Response.Redirect("~/admin/Order/List.aspx");
    }
}